//2009/08/14 00:05:44
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class IPConverter
{
public:
    vector <string> possibleAddresses(string ambig)
    {
        vector<string> ret;
        if (ambig.size() < 4 || ambig.size() > 12) return ret;
        for (int i=1; i<ambig.size(); i++)
        {
            string s1(ambig.substr(0,i));
            stringstream s(s1);
            int a;
            s >> a;
            if ((s1.size()>1 && s1[0]=='0') ||a >255) continue;
            for (int j=1; i+j<ambig.size(); j++)
            {
                string s2(ambig.substr(i,j));
                stringstream ss(s2);
                int b;
                ss >> b;
                if ((s2.size()>1 && s2[0]=='0') ||b >255) continue;
                for (int k=1; i+j+k<ambig.size(); k++)
                {
                    string s3(ambig.substr(i+j, k));
                    stringstream sss(s3);
                    int c;
                    sss >> c;
                    if ((s3.size()>1 && s3[0]=='0') ||c >255) continue;
					
                    string s4(ambig.substr(i+j+k, ambig.size()-(i+j+k)));
                    stringstream ssss(s4);
                    int d;
                    ssss >> d;
                    if ((s4.size()>1 && s4[0]=='0') ||d >255) continue;
					
					char tt[30];
					sprintf(tt, "%d.%d.%d.%d",a,b,c,d);
					ret.push_back(tt);
                }
            }
        }
		return ret;
    }
};
